package edu.tcc.iot.main;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import edu.tcc.iot.controler.IShelfController;
import edu.tcc.iot.controler.impl.ShelfController;

public class CERS {

	private final static Logger log = Logger.getLogger(CERS.class);

	public static void main(String[] args) {
		log.info("Stating CERS");
		initializeLogger();
		CERS app = new CERS();
		app.run();
	}

	private void run() {
		
		log.info("Stating ShelfService");
		IShelfController shelfController = new ShelfController();
		new Thread(shelfController).start();
	}	

	private static void initializeLogger()
	{
		Properties logProperties = new Properties();
		try
		{
			logProperties.load(new FileInputStream("conf/log4j.properties"));
			PropertyConfigurator.configure(logProperties);
			log.info("Logging initialized.");
		}
		catch(IOException e)
		{
			throw new RuntimeException("Unable to load logging property conf/log4j.properties");
		}
	}

}
